﻿<template>

	<div id="app" class="container">
		<!--选择登陆或者注册-->
		<div class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top navSty" style="padding-left: 0;width: 1000px; margin: 0 auto;opacity: 0.88;background-color: #000;">
			<!-- 用户界面功能 -->
			<div style="width: 650px; height: 40px;">
				<ul class="navbar-nav navPos ">
					<li class="nav-item lifl1">
						<router-link to="/queryForum" class="nav-link">查看版块</router-link>
					</li>
					<li class="nav-item lifl2">
						<router-link to="/user" class="nav-link">用户信息</router-link>
					</li>
					<li class="nav-item lifl3">
						<router-link to='/login' class="nav-link" v-if="!this.$store.state.user">登陆</router-link>
						<img src="./image/111.jpg" v-else class="img" />
					</li>
					<li class="nav-item lifl4" v-if="this.$store.state.user">
						<a href="#" @click.prevent="logout" class="nav-link">注销</a>
					</li>
				</ul>
			</div>

			<!--管理员界面功能-->
			<div style="width: 400px; height: 40px;position: absolute; right: 0;" v-if="manage()">
				<ul class="navbar-nav navPos">
					<li class="nav-item lifl1">
						<router-link to='/manageUser' class="nav-link">用户管理</router-link>
					</li>
					<li class="nav-item lifl2">
						<router-link to='/managePost' class="nav-link">帖子管理</router-link>
					</li>
					<li class="nav-item lifl3">
						<router-link to='/manageForum' class="nav-link">版块管理</router-link>
					</li>
					<li class="nav-item lifl4">
						<router-link to='/manageOther' class="nav-link">系统情况</router-link>
					</li>
				</ul>

			</div>
		</div>
		<div>
			<router-view />

		</div>

	</div>
</template>

<script>
	export default {
		name: 'App',
		data() {
			return {
				isLogin: this.$store.state.user,
				level: 0,
			}
		},

		methods: {
			logout() {
				this.$store.commit('removeStorage');
				this.$router.replace({
					path: '/login'
				})

			},
			manage() {
				if(this.$store.state.user != null) {
					if(this.$store.state.user[0].level == 2) {
						return true;
					}
				}
				return false;

			}
		}
	}
</script>

<style scoped>
	#app {
		font-family: 'Avenir', Helvetica, Arial, sans-serif;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
		text-align: center;
		color: #2c3e50;
		margin-top: 60px;
	}
	
	.img {
		width: 40px;
		height: 40px;
		border-radius: 50%;
		margin-left: 5px;
	}
</style>